﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace VAdvantage.UIEvent
{
    public class Event:EventArgs
    {
        private String _name;
        private Control _target;
        private Object _data;
        private bool _propagatable = true;

        public Event(String name, Control target)
        {
            if (name == null)
                throw new NullReferenceException();
            _name = name;
            _target = target;
            _data = null;
        }

        public Event(String name)
        {
            if (name == null)
                throw new NullReferenceException();
            _name = name;
            _target = null;
            _data = null;
        }

        public Event(String name, Control target, Object data)
        {
            if (name == null)
                throw new NullReferenceException();
            _name = name;
            _target = target;
            _data = data;
        }

        public String GetName()
        {
            return _name;
        }

        public Control GetTarget()
        {
            return _target;
        }

        //public Page GetPage() {
        //    return _target != null ? _target.getPage(): null;

        public Object GetData()
        {
            return _data;
        }

        /** Returns whether this event is propagatable.
         * <p>Default: true.
         * <p>It becomes false if {@link #stopPropagation} is called.
         * If true, the event will be sent to the following event listener
         * ({@link EventListener}) being registered by {@link Component#addEventListener}
         * and {@link Page#addEventListener}.
         */
        public bool IsPropagatable()
        {
            return _propagatable;
        }

        public void StopPropagation()
        {
            _propagatable = false;
        }

        //-- Object --//
        public String toString()
        {
            //final String clsnm = getClass().getName();
            //final int j = clsnm.lastIndexOf('.');
            return "[" + _name + ' ' + _target + ']';
        }
    }
}
